{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "20788d12",
   "metadata": {},
   "source": [
    "-------\n",
    "* 2022/10/10 / week07\n",
    "* Python学习记录\n",
    "* 记录人：马梓杰\n",
    "-------"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a1b712f9",
   "metadata": {},
   "source": [
    "# 本周内容\n",
    "\n",
    "* 1. 有序的数据结构——字符串(str)\n",
    "\n",
    "* 2. 有序的数据结构——列表(list)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4ec7a702",
   "metadata": {},
   "source": [
    "## 1. 字符串（string）\n",
    "\n",
    "> 1. 关于字符串的基本内容\n",
    "> 2. 关于字符串的方法及函数"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e637e262",
   "metadata": {},
   "source": [
    "### 1.1 [关于字符串的基本内容](https://docs.python.org/3/tutorial/introduction.html#strings)\n",
    "\n",
    "* Single quotes: 'allows embedded \"double\" quotes'\n",
    "\n",
    "* Double quotes: \"allows embedded 'single' quotes\"\n",
    "\n",
    "* Triple quoted: '''Three single quotes''', \"\"\"Three double quotes\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "dc825bff",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'spam eggs'"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'spam eggs' "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "fe622955",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'str'>\n"
     ]
    }
   ],
   "source": [
    "print(type('spam eggs' ))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "be1d7fde",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'str'>\n"
     ]
    }
   ],
   "source": [
    "print(type(\"spam eggs\" ))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "b02b120f",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (3583323997.py, line 1)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  Input \u001b[1;32mIn [4]\u001b[1;36m\u001b[0m\n\u001b[1;33m    'doesn't'\u001b[0m\n\u001b[1;37m           ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "'doesn't'\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "84d57110",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"doesn't\""
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 以上解决方案\n",
    "\"doesn't\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "0424d204",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"doesn't\""
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'doesn\\'t'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "6f367c62",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 三引号：保留字符串信息的 格式信息,保留完整的数据信息"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "d9a9577a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"doesn't\""
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'''doesn't'''"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "64c9f613",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "EOL while scanning string literal (2251390238.py, line 1)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  Input \u001b[1;32mIn [9]\u001b[1;36m\u001b[0m\n\u001b[1;33m    \"Triple quoted strings may span multiple lines - all associated whitespace will be included in the string literal.\u001b[0m\n\u001b[1;37m                                                                                                                      ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m EOL while scanning string literal\n"
     ]
    }
   ],
   "source": [
    "\"Triple quoted strings may span multiple lines - all associated whitespace will be included in the string literal.\n",
    "\n",
    "String literals that are part of a single expression and have only whitespace between them will be implicitly converted to a single string literal. That is\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "c2892061",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Triple quoted strings may span multiple lines - all associated whitespace will be included in the string literal.\n",
      "\n",
      "String literals that are part of a single expression and have only whitespace between them will be implicitly converted to a single string literal. That is\n"
     ]
    }
   ],
   "source": [
    "print('''Triple quoted strings may span multiple lines - all associated whitespace will be included in the string literal.\n",
    "\n",
    "String literals that are part of a single expression and have only whitespace between them will be implicitly converted to a single string literal. That is''')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "9e8c593c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Usage: thingy [OPTIONS]\n",
      "     -h                        Display this usage message\n",
      "     -H hostname               Hostname to connect to\n",
      "\n"
     ]
    }
   ],
   "source": [
    "print(\"\"\"\\\n",
    "Usage: thingy [OPTIONS]\n",
    "     -h                        Display this usage message\n",
    "     -H hostname               Hostname to connect to\n",
    "\"\"\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "24ecdce7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<script type=\"importmap\" nonce=\"\"> { \"imports\": {\"rms-answers-HomepageVNext-PeregrineWidgets\":\"https://assets.msn.com/bundles/v1/bingHomepage/latest/widget-initializer.js\"} } </script>\n"
     ]
    }
   ],
   "source": [
    "print('''<script type=\"importmap\" nonce=\"\"> { \"imports\": {\"rms-answers-HomepageVNext-PeregrineWidgets\":\"https://assets.msn.com/bundles/v1/bingHomepage/latest/widget-initializer.js\"} } </script>''')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b0412a00",
   "metadata": {},
   "source": [
    "### 1.2 [关于字符串的方法及函数](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str)\n",
    "\n",
    "> 1. 字符串是可以拼接的（字符串的运算）,用 + 进行字符串之间的拼接\n",
    "> 2. 字符串是有顺序的,从第一个字符开始，从0依次往后；有长度，可以用len()检查字符串的长度\n",
    "> 3. 字符串的取值：\n",
    ">> 1. 取单个值 :从左往右（正数，第一个值是0），从右往左（负数，第一个值是-1）\n",
    ">> 2. 取多个值 :切片的方法，两个值作为 取值的区间\n",
    "> 4.字符串的方法及函数\n",
    ">> 1. in 查询成员是否存在\n",
    ">> 2. str.count()查询数量"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "4b943149",
   "metadata": {},
   "outputs": [],
   "source": [
    "new_name = [\"小明\",\"小红\",\"张杰\",\"李华\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "467d9c01",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "广州南方学院团委欢迎小明\n",
      "广州南方学院团委欢迎小红\n",
      "广州南方学院团委欢迎张杰\n",
      "广州南方学院团委欢迎李华\n"
     ]
    }
   ],
   "source": [
    "for i in new_name:\n",
    "    print(\"广州南方学院团委欢迎\"+i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "d8e392e6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'广州南方学院团委欢迎小明'"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"广州南方学院团委欢迎\"+\"小明\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "d806147f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'广州南方学院团委欢迎小明'"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text = '广州南方学院团委欢迎小明'\n",
    "text"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "943cd241",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'广'"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "b30d159e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'州'"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "0981713a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'南'"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text[2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "d2ea9f3a",
   "metadata": {},
   "outputs": [
    {
     "ename": "IndexError",
     "evalue": "string index out of range",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mIndexError\u001b[0m                                Traceback (most recent call last)",
      "Input \u001b[1;32mIn [20]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[43mtext\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m12\u001b[39;49m\u001b[43m]\u001b[49m\n",
      "\u001b[1;31mIndexError\u001b[0m: string index out of range"
     ]
    }
   ],
   "source": [
    "text[12]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ac1c8c1b",
   "metadata": {},
   "outputs": [],
   "source": [
    "len(text)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ff39f889",
   "metadata": {},
   "outputs": [],
   "source": [
    "text[6]+text[7]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "ccdc8542",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'团委'"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 使用 切片 的方法进行多个值取值\n",
    "text[6:8]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0a84822c",
   "metadata": {},
   "source": [
    "* in 查询"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "da9f77cd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'广州' in text"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "6e2149a5",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'北京' in text"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9f785251",
   "metadata": {},
   "source": [
    "* str.count()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "e086e1bd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text.count('广州')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2e0f521e",
   "metadata": {},
   "source": [
    "* str.isdigit('广州')判断字符串是否是数字"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "fd6b7d7c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "19 <class 'int'>\n",
      "19 <class 'str'>\n"
     ]
    }
   ],
   "source": [
    "age_li = 19\n",
    "age_wang = '19'\n",
    "print(age_li,type(age_li))\n",
    "print(age_wang,type(age_wang))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "14b67fda",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "age_wang.isdigit()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "aa5bc54d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text.isdigit()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5eec40a4",
   "metadata": {},
   "source": [
    "## 2. 有序的数据列表——列表(list)\n",
    "* Python knows a number of compound data types, used to group together other values. The most versatile is the list, which can be written as a list of comma-separated values (items) between square brackets. Lists might contain items of different types, but usually the items all have the same type.\n",
    "\n",
    "> 1. 列表的基本运算法则（参考：有序的数据结构的运算法则列表）\n",
    "> 2. 列表的一般方法（要求：全部掌握，并且做总结在课后笔记中）"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c352e1a4",
   "metadata": {},
   "source": [
    "### 2.1 列表的基本运算法则"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "81fdf90d",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 思考：假设，有这样一个场景，我要录入/存放一个班的同学信息（名单信息），用字符串存放是否可行？如何取值呢？\n",
    "#"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "efe52d57",
   "metadata": {},
   "outputs": [],
   "source": [
    "#字符串存放\n",
    "网二_name = \"李华，小明，李晓华，小红\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "15e24a2d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "12"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 字符串取值，比较麻烦\n",
    "len(网二_name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "c64b3bed",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'李华'"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 字符串取值,比较麻烦\n",
    "网二_name[0:2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "6953c11b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'小明'"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_name[3:5]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "400c216a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'李晓华'"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_name[6:9]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e14544f4",
   "metadata": {},
   "source": [
    "* 对比字符串和列表\n",
    "> 1. 字符串是按照字符进行数据取值\n",
    "\n",
    "> 2. 列表是按照元素进行数据取值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "5ae22e5b",
   "metadata": {},
   "outputs": [],
   "source": [
    "网二_name_list = [\"李华\",\"小明\",\"李晓华\",\"小红\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "eea3303b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(网二_name_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "ecea7971",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'李华'"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_name_list[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "916613f9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['李晓华', '小红']"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_name_list[-2:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "829a7551",
   "metadata": {},
   "outputs": [],
   "source": [
    "网二_age_list = [19,18,19,20]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "96fa48d7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "19"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_age_list[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "8e2e8427",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[19, 18, 19, 20]"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_age_list[:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "1d440390",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_age_list.count(19)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "87b96c31",
   "metadata": {},
   "source": [
    "### 2.2 [列表的方法](https://docs.python.org/3/library/stdtypes.html#lists)\n",
    "> 1. 增加\n",
    "> 2. 删除\n",
    "> 3. 修改\n",
    "> 4. 查询in,count"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "ca19495e",
   "metadata": {},
   "outputs": [],
   "source": [
    "names = [\"Mike\",\"marry\",\"jan\",\"jack\"]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3c98bde2",
   "metadata": {},
   "source": [
    "* 学习方法 \n",
    "> 1. listname.Tab键 查看所有方法名称\n",
    "> 2. help(listname.function) 查看其中一个方法的具体操作内容\n",
    "\n",
    "> 课后练习（做一个表格，总结列表的方法）：\n",
    "\n",
    "\n",
    "| 列表方法      | Description | example      |备注|\n",
    "| ----------- | ----------- |----------- |----------- |\n",
    "| append()      |  增加元素，增加在列表的末尾      | names.append(\"zhichao\")，  ['Mike', 'Marry', 'Jan', 'Jack', 'zhichao'] |   |\n",
    "|  count() |  统计某个元素在列表中出现的次数 |  names.count(\"zhichao\"),1 |   |\n",
    "|  extend() |  在列表末尾一次性追加另一个序列中的多个值（用新列表拓展原来的列表） |  ma = [\"zi\", \"jie\"],names.append(ma), ,names ['Mike', 'marry', 'jan', 'jack', 'zhichao', ['zi', 'jie']]|   |\n",
    "|  index() |  从列表中找出某个值第一个匹配项的索引个位置 |  names.index(\"zhichao\"),4 |   |\n",
    "|  insert() |  将对象插入列表 |  names.insert(3,'zijie'),names ['Mike', 'marry', 'jan', 'zijie', 'jack','zhichao'] |   |\n",
    "|  pop() |  移除列表中的一个元素（默认最后一个元素），并返回该元素的值 |  names.pop(0) 'Mike',names  ['marry','jan', 'zijie', 'jack', 'zhichao'] |   |\n",
    "|  remove() |  移除列表中某个值的第一个匹配项 |  names.remove(\"marry\"),names  ['jan', 'zijie', 'jack','zhichao'] |   |\n",
    "|  reverse() |  反向列表中元素 |  names.reverse(),names ['zhichao', 'jack', 'zijie', 'jan'] |   |\n",
    "|  sort() |  对原列表进行排序 |  names.sort(),names ['jack', 'jan', 'zhichao', 'zijie'] |   |\n",
    "|  clear() |  清空列表 |  names.clear(),names [] |   |\n",
    "|  copy() |  复制列表 |  names.copy(),['jack', 'jan', 'zhichao', 'zijie'] |   |\n",
    "|   |   |   |   |\n",
    "| Paragraph   | Text        |   |   |"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "94e0ecc1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function append:\n",
      "\n",
      "append(object, /) method of builtins.list instance\n",
      "    Append object to the end of the list.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(names.append)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "61ca4c16",
   "metadata": {},
   "outputs": [],
   "source": [
    "names.append(\"zhichao\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "fc6fe9f6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Mike', 'marry', 'jan', 'jack', 'zhichao']"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "9038e272",
   "metadata": {},
   "outputs": [],
   "source": [
    "names.insert(3,'zijie')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "8d1d21f6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Mike', 'marry', 'jan', 'zijie', 'jack', 'zhichao']"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "3ba1f7c5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Mike'"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names.pop(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "id": "82c7ecaa",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['marry', 'jan', 'zijie', 'jack', 'zhichao']"
      ]
     },
     "execution_count": 62,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "9cdc9682",
   "metadata": {},
   "outputs": [],
   "source": [
    "names.remove(\"marry\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "468a4c61",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['jan', 'zijie', 'jack', 'zhichao']"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "80bd4092",
   "metadata": {},
   "outputs": [],
   "source": [
    "names.reverse()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "32b1a0c8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['zhichao', 'jack', 'zijie', 'jan']"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "357887de",
   "metadata": {},
   "outputs": [],
   "source": [
    "names.sort()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "id": "cf3c418a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['jack', 'jan', 'zhichao', 'zijie']"
      ]
     },
     "execution_count": 69,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "id": "d1bf11d8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['jack', 'jan', 'zhichao', 'zijie']"
      ]
     },
     "execution_count": 70,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names.copy()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "id": "16839491",
   "metadata": {},
   "outputs": [],
   "source": [
    "names.clear()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "id": "3c8d3530",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[]"
      ]
     },
     "execution_count": 72,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "ab4efa08",
   "metadata": {},
   "outputs": [],
   "source": [
    "ma = [\"zi\", \"jie\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "697b2e28",
   "metadata": {},
   "outputs": [],
   "source": [
    "names.append(ma)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "b49f8ed5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Mike', 'marry', 'jan', 'jack', 'zhichao', ['zi', 'jie']]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6b9735af",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3.10.4 64-bit",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.4"
  },
  "vscode": {
   "interpreter": {
    "hash": "52f15d3cfa1b6a9af5423e55be89f2d13263845687b717213655097fb5509b98"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
